<%@ page language="java" pageEncoding="utf8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>" type="text/css" />
		<link rel="stylesheet" href="<c:url value='/scripts/themes/base/jquery.ui.all.css'/>" type="text/css" />
		<link rel="stylesheet" href="<c:url value='/scripts/skin/ui.dynatree.css'/>" type="text/css" />

	</head>
	<body style="">
		<div id="headBar" class="head_content"></div>
		<div id="main" class="main_content">
			<form method="post" id="model_form" action="sys_delivery_type_area_save.html">
				<input type="hidden" name="orderDeliveryTypeArea.dtId" value="${orderDeliveryType.dtId}" />
				<input type="hidden" name="orderDeliveryTypeArea.dtaId" value="${orderDeliveryTypeArea.dtaId}" />
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">

						<tr>
							<th>
								配送方式名称:
							</th>
							<td>
								${orderDeliveryType.dtName}
							</td>
							<th>
								&nbsp;
							</th>
							<td>
								&nbsp;
							</td>
						</tr>

					</table>
				</div>

				
				<div id="deliveryAreabox" class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									支持的配送地区:
								</th>
								<td>

									<div class="deliverycity">

										<input id="area_id_names" value="${orderDeliveryTypeArea.areaNameGroup }" readonly="true" name="orderDeliveryTypeArea.areaNameGroup" style="width: 300px;" />
										<input id="area_ids" type="hidden" value="${orderDeliveryTypeArea.areaIdGroup }" name="orderDeliveryTypeArea.areaIdGroup">
									</div>


								</td>
							</tr>
							<tr>
								<th>
									费用:
								</th>
								<td>

									<div class="deliverycity">

										<input name="orderDeliveryTypeArea.basicFee" value="${orderDeliveryTypeArea.basicFee }" />
										<input value="${orderDeliveryTypeArea.additionalFee}" name="orderDeliveryTypeArea.additionalFee" />
									</div>


								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="division">
					<div id="tree2">
						<ul>
							<c:forEach items="${systemRegions}" var="region">
								<c:if test="${region.parentId == 0}">
									<li id="${region.regionId }" class="folder" data="key: '${region.regionId}',localname:'${region.localName}'">
										${region.localName}
										<ul>
											<c:forEach items="${region.subSystemRegions}" var="second">
												<li id="${second.regionId}" class="folder" data="key: '${second.regionId}',localname:'${second.localName}'">
													${second.localName}
													<ul>
														<c:forEach items="${second.subSystemRegions}" var="third">
															<li id="${third.regionId}" data="key: '${third.regionId}',localname:'${third.localName}',select:${third.selected }">
																${third.localName}
															</li>
														</c:forEach>
													</ul>
												</li>
											</c:forEach>
										</ul>
									</li>
								</c:if>
							</c:forEach>
						</ul>
					</div>
				</div>
				<div class="division">
				</div>
				<div class="table-action">
					<button class="btn" type="submit">
						<span><span>保存</span> </span>
					</button>
				</div>
			</form>
		</div>
		<div id="footBar" class="foot_content"></div>



		<script type="text/javascript" src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/jquery.validate.js'/>"></script>

		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.core.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.widget.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/jquery.dynatree.js'/>"></script>


		<script type="text/javascript">
	$(document).ready(
			function() {
				$("#tree2").dynatree(
						{
							checkbox : true,
							selectMode : 3,
							onSelect : function(select, dtnode) {
								// Get a list of all selected nodes, and convert to a key array:
							var selKeys = $.map(dtnode.tree.getSelectedNodes(),
									function(node) {
										return node.data.key;
									});
							var selLocalnames = $.map(dtnode.tree
									.getSelectedNodes(), function(node) {
								return node.data.localname;
							});

							$("#area_ids").val(selKeys.join(", "));
							// Get a list of all selected TOP nodes
							var selRootNodes = dtnode.tree
									.getSelectedNodes(true);
							// ... and convert to a key array:
							var selRootKeys = $.map(selRootNodes,
									function(node) {
										return node.data.localname;
									});
							$("#area_id_names").val(selRootKeys.join(", "));
						},
						onDblClick : function(dtnode, event) {
							dtnode.toggleSelect();
						},
						onKeydown : function(dtnode, event) {
							if (event.which == 32) {
								dtnode.toggleSelect();
								return false;
							}
						}
						});

				var validator = $("#model_form").validate( {
					errorElement : "div",
					errorClass : "x-vali-error",
					onfocusout : false,
					rules : {
						'orderDeliveryType.dtName' : "required",
						'orderDeliveryType.detail' : "required",
						'orderDeliveryType.showOrder' : {
							required : true,
							number : true
						},
						'orderDeliveryType.basicUnit' : {
							required : true,
							number : true
						},
						'orderDeliveryType.additionalUnit' : {
							required : true,
							number : true
						},
						'orderDeliveryType.basicFee' : {
							required : true,
							number : true
						},
						'orderDeliveryType.additionalFee' : {
							required : true,
							number : true
						},
						'orderDeliveryType.protectRate' : {
							required : true,
							number : true
						},
						'orderDeliveryType.protectMinPrice' : {
							required : true,
							number : true
						}
					},
					messages : {
						'orderDeliveryType.dtName' : "必填字段",
						'orderDeliveryType.detail' : "必填字段",
						'orderDeliveryType.showOrder' : {
							required : "必填字段",
							number : "请填入数字"
						},
						'orderDeliveryType.basicUnit' : {
							required : "必填字段",
							number : "请填入数字"
						},
						'orderDeliveryType.additionalUnit' : {
							required : "必填字段",
							number : "请填入数字"
						},
						'orderDeliveryType.basicFee' : {
							required : "必填字段",
							number : "请填入数字"
						},
						'orderDeliveryType.additionalFee' : {
							required : "必填字段",
							number : "请填入数字"
						},
						'orderDeliveryType.protectRate' : {
							required : "必填字段",
							number : "请填入数字"
						},
						'orderDeliveryType.protectMinPrice' : {
							required : "必填字段",
							number : "请填入数字"
						}
					},
					errorPlacement : function(error, element) {
						element.removeClass('x-vali-error');
						error.appendTo(element.parent());

					},

					success : function(div) {
						$(div).remove();
					}
				});
			});
</script>
	</body>
</html>